package com.zt.springcloud;

import com.zt.springcloud.entity.Cart;
import com.zt.springcloud.entity.Vo.CartVo;
import com.zt.springcloud.entity.Product;
import com.zt.springcloud.factory.RemoteUserFallbackFactory;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Set;

@FeignClient(contextId = "RemoteProductService",value = "cloud-system",fallbackFactory = RemoteUserFallbackFactory.class)
public interface RemoteProductService {
    /**
     * 查询所有食物商品
     *
    **/
    @GetMapping("/foodProduct/getAllFoodItem")
    public Set<Product> getAllFoodItem();

    /**
     * 根据id查询商品信息
     *
     **/
    @GetMapping("/item/info/{productId}")
    public Product getItemInfo(@PathVariable("productId") Long productId);
    /*
    * 添加购物车
    * */
    @RequestMapping(value = "/shopcart/add",method = RequestMethod.POST)
    public Boolean addShopCart(@RequestBody Cart cart);


    /*查詢所有购物车商品*/
    @RequestMapping(value = "/shopcart/list")
    public List<CartVo> getCartList(@RequestParam("id") Long id);

    /*
     * 增加购物车中商品的购买数量
     * */
    @RequestMapping(value = "/shopcart/addAmount/{itemId}",method = RequestMethod.PUT)
    public Integer addShopCartAmount(@PathVariable("itemId") Long itemId);
    /*
     * 减少购物车中商品的购买数量
     * */
    @RequestMapping(value = "/shopcart/minusAmount/{itemId}",method = RequestMethod.PUT)
    public Integer minusShopCartAmount(@PathVariable("itemId") Long itemId);

    /*
     * 根据itemId查询购物车的商品
     * */
    @RequestMapping(value = "/shopcart/listByIds",method = RequestMethod.POST)
    public List<CartVo> findItemsByIds(@RequestBody String itemIds);
}
